# coding=utf-8
#from django.shortcuts import render_to_response
from django.http import HttpResponse

class Response():
    @staticmethod
    def json(info):
        from django.utils import simplejson
        return HttpResponse(simplejson.dumps(info,encoding='utf-8'))
        
    @staticmethod
    def gridJson(info):
        from django.utils import simplejson
        import datetime,decimal 
        items = info['items']
        for item in list(items):
            for key in item.keys():
                if isinstance(item[key], datetime.datetime):  
                    item[key] =  item[key].strftime('%Y-%m-%d %H:%M:%S')
                elif isinstance(item[key], datetime.time):  
                    item[key] =  item[key].strftime('%H:%M:%S')
                elif isinstance(item[key], datetime.date):  
                    item[key] =  item[key].strftime('%Y-%m-%d')
                elif isinstance(item[key], decimal.Decimal):  
                    item[key] = str(item[key])
        return HttpResponse(simplejson.dumps(info,encoding='utf-8'))
    
    class ActionType():
        refresh = 'refresh'
        reloadGrid = 'reloadGrid'
        redirect = 'redirect'
        resetForm = 'resetForm'
        closeWindow = 'closeWindow'
        alert = 'alert'
    
    
    
    
        